<!DOCTYPE html>
<html>
	<head>
	<title>宣传培训</title>
		<meta http-equiv="Pragma" CONTENT="no-cache">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="renderer" content="webkit">

		<%include("/common/include.html"){}%>
		<style type="text/css">
			#training ul li{
				margin-top:20px;
			}
		</style>
	</head>
	<body>
		<form id="training"   method="post"  enctype="multipart/form-data" style="border:1px solid #ffffff;">
			<div id="contentx" style="width:500px;height: auto;margin:auto;">
				<ul>
					<li style="margin-top:0px">
						<span style="margin-left:25px;font-weight: bold;">活动时间</span>
						<input name="training.training_time" value="date()" class="easyui-datebox theme-textbox-radius" data-options="sharedCalendar:'#cc'"  style="width: 80%;height: 40px;"> 
					</li>	
					<div id="cc" class="easyui-calendar"></div>				
					<li>
						<span style="margin-left:25px;font-weight: bold;">培训内容</span>
						<input name="training.trainings"  class="easyui-textbox theme-textbox-radius" data-options="multiline:true"  style="width:80%;height:100px">
					</li>
					<li>
						<span style="margin-left:25px;font-weight: bold;">培训结果</span>
						<input name="training.training_result" class="easyui-textbox theme-textbox-radius" data-options="multiline:true"  style="width:80%;height:100px">
					</li>
					<li>
						<span style="margin-left:25px;font-weight: bold;">参加人员</span>
						<a href="javascript:void(0);" class="easyui-linkbutton" style="height: 32px;width:100px;background: #00A65A;color: white;" onclick="$('#w').window('open')">请&nbsp;&nbsp;选&nbsp;&nbsp;择</a>								
					</li>
					<li style="width:75px;margin:auto;">
						<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="save1()"style="height:32px;margin-top: 30px;">保存</a>
					</li>							
				</ul>
			</div>
		</form>		
		<!--门店人员开头 -->	   
		<div id="w" class="easyui-window" title="请选择" data-options="collapsible:false,minimizable:false,maximizable:false,closable:true,resizable:true" style="width:750px;height:500px;padding:5px;" data-options="cls:'theme-panel-orange'" closed="true">
			<div class="easyui-layout" data-options="fit:true">
				<form id="allData_form">
					<div data-options="region:'west'" style="width:30%">
						<%include("/btraining/trainningPropTree.html", {'gridId':'deptTable'}){}%>
					</div>
					<div data-options="region:'center'">
						<table id="deptTable" style="height:100%"></table>
					</div>
					<div data-options="region:'south',border:true" style="height:50px;position:relative;">
						<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="confirm()" style="position:absolute;right:10px;top:8px;">确定</a>
					</div>
				</form>
			</div>
		</div> 
		<!-- 门店人员结尾-->		
		<script src="${cxt !}/sb/js/jquery.form.js" type="text/javascript" charset="utf-8"></script>
	
		<script type="text/javascript">
		//页面加载时
		window.onload = function(){
			var winH = $(window).height();
			var contentx = document.getElementById("contentx");
			var contentxH = $("#contentx").height();
			var padding=(winH-contentxH)/2;
			contentx.style.marginTop=padding+"px"; 
		}
		//窗口大小改变时
		window.onresize = function(){
			var winH = $(window).height();
			var contentx = document.getElementById("contentx");
			var contentxH = $("#contentx").height();
			var padding=(winH-contentxH)/2;
			contentx.style.marginTop=padding+"px"; 
		}	
		//数据表格复选框全选
		function selectAllBox(){  
			  $('#deptTable').datagrid('selectAll');    
		}  
		
		//门店人员
		function initDeptTable(t){
		
							$('#deptTable').datagrid({
								cls: "theme-datagrid",
								title: "人员列表",
								rownumbers: true, //显示序号
								pagination: false,
								fitColumns:true,
								//pageSize: 10,
								url: "departmentUser/personnelList",
								queryParams: {
									'_query.bh': t 
								},
							    method: 'post',
				collapsible: true,
				columns:[[
							{field:'check',checkbox:true},
					  		{field:'ids',title:'ids',width:100,align:'center', hidden:true},
					  		{field:'username',title:'用户名',width:100,align:'center', hidden:true},
					  		{field:'name',title:'姓名',width:100, align:'center'
					  			/*,
					  			formatter: function(value,row,index){
					  				var ids = row.ids;
									return '<a href="#" style="color: blue;" class="button-edit" onclick="lookInfo(\'' + ids + '\')">' + value + '</a>';
								}*/
					  		},
					  		{field:'dname',title:'部门',width:100, align:'center'},
					  		
					  		{field:'stationname',title:'岗位',width:100, align:'center'},
					  		{field:'mobile',title:'联系方式',width:160, align:'center'},
					  		{field:'status',title:'状态',width:100, align:'center', hidden:true
					  			/*formatter: function(value,row,index){
					  				var status = row.status;
					  				if(status == 1){
					  					return '正常';
					  				}else{
					  					return '禁用';
					  				}
					  			}*/
					  		}
					      ]],
				onLoadSuccess:selectAllBox 
			});
		}	 
		//确认参加人员
		 function confirm(){	
			
			
			$('#w').window('close');
		} 
			function  save1()
			{	
				var checkRows=$('#deptTable').datagrid('getChecked');
				var name = "";
				for(var i=0;i<checkRows.length;i++)
				{	
					$("#allData").html("");
					 var rowIndex = $('#deptTable').datagrid('getRowIndex', checkRows[i]);
					 $('#deptTable').datagrid('endEdit', rowIndex);
					//var ids = checkRows[i].ids;			
					name = name+checkRows[i].name+",";
					
				}		
				
				$("#training").append("<input type='hidden' name='training.training_personnel' value='"+name+"'/>");
					$.ajax({
		                cache: true,
		                type: "POST",
		                url:"${cxt !}/btraining/saveTra",
		                data:$('#training').serialize(),// 你的formid
		                dataType:'json',
		                async: false,
		                success: function(result) {
		                	
		                	if(result.msg == "200")
		                	{	
		                		 $.slideMsg("保存成功", parent.$);
		                		 parent.refresh();
		                	}else{	                		
		                		$.alert(parent.$, result.msg);	        				
		                	}
		                }
		            });
				}
		//设置当前日期
		date = function () {
			var date=new Date();
			var day = date.getDate() > 9 ? date.getDate() : "0" + date.getDate();
			var month = (date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : "0"
			+ (date.getMonth() + 1);
			var hor = date.getHours();
			var min = date.getMinutes();
			var sec = date.getSeconds();
			return date.getFullYear() + '-' + month + '-' + day+" "+hor+":"+min+":"+sec;
		};
		</script>
	</body>
</html>
